/* Federal University of Minas Gerais (UFMG)
 * Software Engineering Laboratory (LabSoft)
 * SimulES-SPL Project
 */

package br.ufmg.dcc.simulesspl.model;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo;
import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.junit.Test;

import br.ufmg.dcc.simulesspl.model.EngineerCard;

/**
 * 
 * @author Patrick Prado
 * 
 *         Testes das propriedades da classe CardProject
 */

public class EngineerCardTest {

	@Test
	public void generationOfCardsShouldReturnValidCards() {
		
		List<EngineerCard> cards = EngineerCard.create(10);
		
		assertThat(cards.size(), equalTo(10));
		
		for(EngineerCard card : cards) {
			assertThat(card.getVelocity(), allOf(greaterThanOrEqualTo(1), lessThanOrEqualTo(5)));
			assertThat(card.getSkill(), allOf(greaterThanOrEqualTo(1), lessThanOrEqualTo(5)));
			assertThat(card.getCost(), allOf(greaterThanOrEqualTo(1), lessThanOrEqualTo(5)));
		}
	}
	
	@Test
	public void testBugProbability() {
		EngineerCard p50 = new EngineerCard(1, 1, 1);
		assertThat(p50.getBugProbability(), closeTo(0.5, 0.001));
		
		EngineerCard p40 = new EngineerCard(1, 2, 1);
		assertThat(p40.getBugProbability(), closeTo(0.4, 0.001));
		
		EngineerCard p30 = new EngineerCard(1, 3, 1);
		assertThat(p30.getBugProbability(), closeTo(0.3, 0.001));
		
		EngineerCard p20 = new EngineerCard(1, 4, 1);
		assertThat(p20.getBugProbability(), closeTo(0.2, 0.001));
		
		EngineerCard p10 = new EngineerCard(1, 5, 1);
		assertThat(p10.getBugProbability(), closeTo(0.1, 0.001));
		
	}
}
